<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%     
	String path = request.getContextPath();     
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";     
%>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>新增风险</title>
	<base href="<%=basePath%>"/>
	<%@ include file="../../cuv_include.jsp"%>
	<style type="text/css"> 
	  fieldset,legend,form,table,tr,td,textarea{margin:0;padding:0}
	  form label {font-weight:bold;}
	  table{margin:10px 10px};
	  td{line-height: 40px;}
	  input[type="text"]{width:250px;}
	  input[type="password"]{width:250px;}
	  input[type="textarea"]{width:250px;}
	</style>
    <script type="text/javascript">
    function btn_return(){
        location.href = "<%=basePath%>soft/riskManager/list.do?projectId=" + $("#projectId").val();
    }
	  $(document).ready(function(){
	      $("#description").focus();
	      var options = {dataType: 'json', beforeSubmit: beforeSubmit, success: process};
	      $("#riskForm").submit(function(){
	          $(this).ajaxSubmit(options);
	          return false;
	      });      
	  });
	  
	  function beforeSubmit() {
	      if(isEmpty($("#description").val())) { alert("描述不能为空！"); return false; }
	      
	      if(isEmpty($("#riskType").val())) { alert("类型不能为空！"); return false; }
	
	      return true;
	  }

     function process(responseJson) {
          if(responseJson.code == 0) {
           $('#error_label').text("错误信息：" + responseJson.message);
           $("#p_error").show();
               return;
            }
	      location.href = "<%=basePath%>soft/riskManager/list.do?projectId=" + $("#projectId").val();
      }  
</script>
</head>
<body>
  <div>
    <fieldset>
      <legend>新增风险：</legend>
      <form id="riskForm" method="post" action="soft/riskManager/add.do">
       <input type="hidden" name="projectId" id="projectId" value="${projectId }">
       <input id="qs" name="qs" type="hidden" value="${qs}"/>
      	<p id = "p_error" style = "margin:10px 10px;">
      	    <label id="error_label" style="color:red;"></label>
      	</p>
        <table>
          <tr>
            <td><label for="version">项目名称：</label></td>
            <td>
            	<input type="text" name="project" id="project"  disabled="disabled" value="${projectName}" />
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
          </tr>
          <tr>
            <td><label for="name">风险类型：</label></td>
			<td>
				 <select name="riskType" id="riskType">
						<c:forEach var="item" items="${itemList}" varStatus="status">
							<option value="${item.value}">${item.name}</option>
						</c:forEach>
				 </select>
                 <font color="red">&nbsp;*&nbsp;&nbsp;</font> 
            </td>
          </tr>
          <tr>
            <td><label for="status">状态：</label></td>
            <td>
            	<select name="status" id="status">
					<c:forEach var="item" items="${riskStatus}" varStatus="status">
						<option value="${item.value}">${item.name}</option>
					</c:forEach>
				</select>
            </td>
          </tr>     
          <tr>
            <td><label for="description">风险描述：</label></td>
            <td>
            	<textarea name="description" id="description" cols="40" rows="8"><c:out value="${group.remark }"/></textarea>
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            	<label for="name">小于500个字符</label>
            </td>
          </tr>            
          <tr>
            <td></td>
            <td>
            	<input type="submit" id="btn_insert" value="提交" style="width:80px;" />
            	<input type="button" id="btn_back" value="返回" onclick="btn_return();" style="width:80px;" />
            </td>
          </tr>
        </table>
      </form>
    </fieldset>
  </div>
</body>
</html>